﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace ShevaEngine.Core.Modules.ArtificialIntelligence.Pathfinding
{
    /// <summary>
    /// Distance heuristic.
    /// </summary>
    public class DistanceHeuristic : Heuristic
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="node"></param>
        public DistanceHeuristic()
        {
        }

        /// <summary>
        /// Method computes estimate cost.
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public override float Estimate(NavigationGraphNode node)
        {
            Vector3 vertex1 = Vector3.Zero;
            Vector3 vertex2 = Vector3.Zero;

            if (node is NavigationGraphNodeQuad2D)
                vertex1 = (node as NavigationGraphNodeQuad2D).Quad.Center;

            if (this.EndNode is NavigationGraphNodeQuad2D)
                vertex2 = (this.EndNode as NavigationGraphNodeQuad2D).Quad.Center;

            return Vector3.DistanceSquared(vertex1, vertex2);
        }
    }
}
